﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Web.UI.WebControls;
using System.Web.UI;
using System.Web.UI.HtmlControls;

using AjaxControlToolkit;
using BizElements.Core;
using BizElements.BusinessLayer;

namespace BizElements.Web
{
    /// <summary>UI component (user control) for editing IDataObjectUI business objects.</summary>
    public interface IDataObjectUI
    {
        #region Properties.

        /// <summary>Programmatic identifier assigned to server control.</summary>
        string ID { get; }

        /// <summary>Business object bound to user control.</summary>
        IDataObject BizObject { get; set; }

        /// <summary>Specifies whether to hide command buttons such as: save, deactivate, cancel...</summary>
        bool ButtonsHidden { get; set; }

        /// <summary>Specifies whether to hide header and footer controls.</summary>
        bool HeaderAndFooterHidden { get; set; }

        /// <summary>Specifies whether to bind business object in readonly mode.</summary>
        bool ReadOnly { get; set; }

        /// <summary>Specified whether the control is visible in UI.</summary>
        bool Visible { get; set; }

        #endregion

        #region Methods.

        /// <summary>Parses and valites business object bound to UI.</summary>
        bool PopulateAndValidateBusinessObject();

        /// <summary>Refreshes/redraws the user control.</summary>
        void Refresh();

        /// <summary>Changes business object access mode and propagates it to all bound controls.</summary>
        /// <param name="accessMode">Access mode.</param>
        /// <param name="doRefresh">Indicates whether the control should automatically refresh itself. Set to <b>false</b> if you will call <see cref="Refresh"/> method manually.</param>
        void ForceAccessMode(FieldAccessMode accessMode, bool doRefresh);

        #endregion

        #region Events.

        /// <summary>Occurs when a new parent entity should be created via its dedicated form.</summary>
        event EventHandler<EventArgs<WebFormContext>> NewParent;

        /// <summary>Occurs when an existing parent entity should be edited or viewed in its dedicated form.</summary>
        event EventHandler<EventArgs<WebFormContext>> OpenParent;

        #endregion
    }
}
